﻿<UserControl x:Class="Arma3BEClient.Chat.ChatControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d"  DataContextChanged="ToolBar_DataContextChanged" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
             >
    <Grid >

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition></RowDefinition>
        </Grid.RowDefinitions>

        <ToolBar>

            <CheckBox Content="Enable chat" IsChecked="{Binding EnableChat, Mode=TwoWay}"></CheckBox>
            <Separator></Separator>
            <CheckBox Content="Auto scroll" IsChecked="{Binding AutoScroll, Mode=TwoWay}"></CheckBox>
            <Separator></Separator>
            <Button Content="History" Command="{Binding ShowHistoryCommand}"></Button>
            <Button Content="Clear all" Click="ClearAll_Click"></Button>
        </ToolBar>

        <TabControl Grid.Row="1" TabStripPlacement="Left" >


            <TabControl.Resources>
                <Style TargetType="{x:Type TabItem}">
                    <Setter Property="HeaderTemplate">
                        <Setter.Value>
                            <DataTemplate>
                                <ContentPresenter Content="{TemplateBinding Content}">
                                    <ContentPresenter.LayoutTransform>
                                        <RotateTransform Angle="270" />
                                    </ContentPresenter.LayoutTransform>
                                </ContentPresenter>
                            </DataTemplate>
                        </Setter.Value>
                    </Setter>
                    <Setter Property="Padding" Value="3" />
                </Style>
            </TabControl.Resources>


            <TabItem Header="Chat">

                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition></RowDefinition>
                        <RowDefinition Height="Auto"></RowDefinition>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition></ColumnDefinition>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                    </Grid.ColumnDefinitions>

                    <ScrollViewer Grid.ColumnSpan="2" Name="ChatScrollViewer">

                        <RichTextBox Name="msgBox"  HorizontalAlignment="Stretch" VerticalAlignment="Stretch"  IsReadOnly="True" IsReadOnlyCaretVisible="False"
                             FontSize="14" FontWeight="Medium"  FontStyle="Normal" Background="#F0F0F0">
                            <RichTextBox.Resources>
                                <Style TargetType="{x:Type Paragraph}">
                                    <Setter Property="Margin" Value="0"/>
                                </Style>
                            </RichTextBox.Resources>
                        </RichTextBox>

                    </ScrollViewer>


                    <TextBox Name="tbNewMessage" Grid.Row="1" Grid.Column="0" Margin="2" Text="{Binding InputMessage, Mode=TwoWay}"  KeyDown="KeyDown"  Height="20" ></TextBox>
                    <Button Grid.Row="1" Grid.Column="1" Content="Send" Margin="2" Click="SendMessage"></Button>

                </Grid>

            </TabItem>
            <TabItem Header="Console">

                <ScrollViewer Grid.ColumnSpan="2" Name="ConsoleScrollViewer">

                    <RichTextBox Name="msgConsole"  HorizontalAlignment="Stretch" VerticalAlignment="Stretch"  IsReadOnly="True" IsReadOnlyCaretVisible="False"
                             FontSize="12" FontWeight="Normal"  FontStyle="Normal" Background="#F0F0F0">
                        <RichTextBox.Resources>
                            <Style TargetType="{x:Type Paragraph}">
                                <Setter Property="Margin" Value="0"/>
                            </Style>
                        </RichTextBox.Resources>
                    </RichTextBox>

                </ScrollViewer>
            </TabItem>

        </TabControl>



    </Grid>
</UserControl>
